<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增客户信息')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-vo-add">
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">客户名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="custName" id="custName" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">客户类型：</label>
				<div class="col-sm-8">
		            <input id='custTypePerson' name="custType" th:checked="true" type="radio" value="0">
		            <label for="unStart" style="margin-bottom:5px;">个人</label>
		            <input id='custTypeCompany' name="custType" th:checked="false" type="radio" value="1">
		            <label for="unStart" style="margin-bottom:5px;">单位</label>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">社会信用代码/身份号码：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="certNo" id="certNo" required>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "crm/custinfo";
	    
		$("#form-vo-add").validate({
			onkeyup: false,
			rules:{
				custName:{
					remote: {
		                url: ctx + "crm/custinfo/checkNameUnique",
		                type: "post",
		                dataType: "json",
		                data: {
		                	"custName" : function() {
		                        return $.common.trim($("#custName").val());
		                    }
		                }
		            }
				},
			},
			messages: {
		        "custName": {
		            remote: "客户信息名称已经存在"
		        }
		    },
		    focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/add", $('#form-vo-add').serialize(), function() {
	        		$.modal.alertSuccess('保存成功！');
	        		$.modal.close();
        			}
        		);
	        }
	    }
	</script>
</body>
</html>
